# Contributor: Russ Webber <russ@rw.id.au>
# Maintainer: Russ Webber <russ@rw.id.au>
pkgname=vcstool
pkgver=0.3.0
pkgrel=3
pkgdesc="A command line tool designed to make working with multiple repositories easier"
url="https://github.com/dirk-thomas/vcstool"
arch="noarch"
license="Apache-2.0"
depends="python3 py3-yaml"
makedepends="py3-setuptools"
checkdepends="py3-pytest py3-flake8 py3-pydocstyle py3-flake8-import-order subversion mercurial git"
subpackages="
	$pkgname-pyc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-tcsh-completion:tcshcomp:noarch
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/dirk-thomas/vcstool/archive/$pkgver.tar.gz"
options="!check" # fail due to  various git errors, and outdated dependency expectations

build() {
	python3 setup.py build
}

check() {
	PYTHONPATH="$builddir/build" pytest -s -v test -k 'not test_import_shallow'
}

package() {
	python3 setup.py install --skip-build --root="$pkgdir"

	mkdir -p "$pkgdir"/usr/share/bash-completion/completions
	mkdir -p "$pkgdir"/usr/share/zsh/site-functions
	mkdir -p "$pkgdir"/usr/share/tcsh-completion/completions
	mv "$pkgdir"/usr/share/vcstool-completion/vcs.bash "$pkgdir"/usr/share/bash-completion/completions
	mv "$pkgdir"/usr/share/vcstool-completion/vcs.zsh "$pkgdir"/usr/share/zsh/site-functions
	mv "$pkgdir"/usr/share/vcstool-completion/vcs.tcsh "$pkgdir"/usr/share/tcsh-completion/completions
	rm -rf "$pkgdir"/usr/share/vcstool-completion
}

tcshcomp() {
	pkgdesc="tcsh completions for $pkgname"
	depends=""
	install_if="$pkgname=$pkgver-r$pkgrel tcsh"

	amove /usr/share/tcsh-completion/completions
}

sha512sums="
f50ec4c23fce65f71ec0070b709840150f6a90b0620dd937c234c408951b4eb6ad9d53d841d3862ce7ece54c15458fd9db434341fd4a1eabb40a7084fb71b101  vcstool-0.3.0.tar.gz
"
